package com.mustafaiev.tair.cts.tapestry.mixins;

import org.apache.tapestry5.ClientElement;
import org.apache.tapestry5.annotations.Environmental;
import org.apache.tapestry5.annotations.Import;
import org.apache.tapestry5.annotations.InjectContainer;
import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.javascript.JavaScriptSupport;

@Import(library = { "context:layout/js/Disabler.js" })
public class Disabler {

    @Environmental
    private JavaScriptSupport javaScriptSupport;

    @InjectContainer
    private ClientElement clientElement;

    void afterRender() {
        // Add some JavaScript to the page to instantiate a ZoneUpdater. It will
        // run when the DOM has been fully loaded.

        final JSONObject spec = new JSONObject();

        spec.put("elementId", clientElement.getClientId());

        javaScriptSupport.addInitializerCall("disabler", spec);
    }

}
